//
//  MacroHeader.h
//  VirtualCurrency
//
//  Created by apple on 2021/7/5.
//

#ifndef MacroHeader_h
#define MacroHeader_h

//正式环境地址
#define BASE_URL @"http://122.10.18.51/app/"

/** 屏幕bounds */
#define IDBounds [UIScreen mainScreen].bounds
/** 屏幕size */
#define IDSize IDBounds.size
#define IDWidth IDSize.width
#define IDHeight IDSize.height

// 适配不同屏幕 以6屏幕为基准
#define iphone4_scale_w 0.853
#define iphone4_scale_h 0.720
#define iphone5_scale_w 0.853
#define iphone5_scale_h 0.851
#define iphone6_scale_w 1.0
#define iphone6_scale_h 1.0
#define iPhone6Plus_scale_w 1.104
#define iPhone6Plus_scale_h 1.103
#define iPhoneX_scale_w 1.0
#define iPhoneX_scale_h 1.0 // 1.217
#define iPhone12_scale_w 1.04
#define iPhone12_scale_h 1.0 // 1.265
#define iPhone12Max_scale_w 1.141
#define iPhone12max_scale_h 1.103 // 1.388
#define iPhoneXSMax_scale_w 1.104
#define iPhoneXSMax_scale_h 1.103 // 1.343

#define isIphone4 (IDHeight == 480.0 ? YES : NO)
#define isIphone5 (IDHeight == 568.0 ? YES : NO)
#define isIphone6 (IDHeight == 667.0 ? YES : NO)
#define isIphone6P (IDHeight == 736.0 ? YES : NO)
// X XS 11PRO 12MIN
#define isiPhoneX ((IDWidth == 375.0 && IDHeight == 812.0) ? YES : NO)
// 12 12PRO
#define isiPhone12 ((IDWidth == 390.0 && IDHeight == 844.0) ? YES : NO)
#define isiPhone12Max ((IDWidth == 428.0 && IDHeight == 926.0) ? YES : NO)
// 11 xsmax xr 11promax
#define isiPhoneXSMax ((IDWidth == 414.0 && IDHeight == 896.0) ? YES : NO)


//字体
#define IDFont(font) [UIFont systemFontOfSize:IDWPercentage(font)]

#define naviH (IPHONE_X ? 88 : 64)

#define kBottomSafeMargin (IPHONE_X ? 34.f : 0.f)

#define kTitleLabelHeight (IPHONE_X ? 44.f : 20.f)

#define kPoorWithiPhoneX (IPHONE_X ? 22.f : 0.f)

#define kTabbarHeight (kBottomSafeMargin + 49)
//以iphone6/7为基准进行屏幕适配
#define YHEIGHT(y) (isIphone4 ? floor(y*iphone4_scale_h) : isIphone5 ? floor(y*iphone5_scale_h) : isIphone6 ? floor(y*iphone6_scale_h) : isIphone6P ? floor(y*iPhone6Plus_scale_h) : isiPhoneX ? floor(y*iPhoneX_scale_h) :  isiPhone12 ? floor(y*iPhone12_scale_h) : isiPhone12Max ? floor(y*iPhone12max_scale_h) : isiPhoneXSMax ? floor(y*iPhoneXSMax_scale_h) : y)

#define XWIDTH(x) (isIphone4 ? floor(x*iphone4_scale_w) : isIphone5 ? floor(x*iphone5_scale_w) : isIphone6 ? floor(x*iphone6_scale_w) : isIphone6P ? floor(x*iPhone6Plus_scale_w) : isiPhoneX ? floor(x*iPhoneX_scale_w) :  isiPhone12 ? floor(x*iPhone12_scale_w) : isiPhone12Max ? floor(x*iPhone12Max_scale_w) : isiPhoneXSMax ? floor(x*iPhoneXSMax_scale_w) : x)

#define isLogin [LoginManager shared].loginToken.length > 0

#define KEYWINDOW  [UIApplication sharedApplication].keyWindow

#define ScreenWidth [UIScreen mainScreen].bounds.size.width
#define ScreenHeight [UIScreen mainScreen].bounds.size.height

#define IPHONE_X \
({BOOL isPhoneX = NO;\
if (@available(iOS 11.0, *)) {\
isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
}\
(isPhoneX);})




//字符串颜色
#define ColorHexString(a) [UIColor colorWithHexString:a]

//背景颜色
#define bGColor ColorHexString(@"#f2f2f2")
//主题颜色
#define Main_Blue ColorHexString(@"#0B7DFF")


//颜色
#define IDColor(r,g,b,a)    [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

#define HIDEKEYBOARD  [[UIApplication sharedApplication].keyWindow endEditing:YES]

#define kDictIsEmpty(dic) ([dic isKindOfClass:[NSNull class]])

#define mainFont [UIFont systemFontOfSize:XWIDTH(14)]
#define detailFont [UIFont systemFontOfSize:XWIDTH(12)]
#define normalFont [UIFont systemFontOfSize:XWIDTH(16)]
#define maxFont [UIFont fontWithName:@"Helvetica-Bold" size:XWIDTH(18)]

//字体及字体大小
#define Font(x)               [UIFont systemFontOfSize:x]//[UIFont fontWithName:@"HelveticaNeue-Thin" size:x]//
#define Bold_Font(x)          [UIFont fontWithName:@"Helvetica-Bold" size:x]
//获取图片资源
#define GetImage(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@", imageName]]
//语言适配
#define k_Language(str) NSLocalizedString(str, nil)

#define kWeakly(self) typeof(self) __weak weakself = self;


#endif /* MacroHeader_h */
